﻿@model Ymca.Web.Models.Blog.PostDetailsViewModel

<h2>@string.Format("{0} {1}", Model.Date, Model.Title)</h2>
@(new HtmlString(Model.Body))
<span>Comments: @Model.Comments.Count()</span>
<span>Attachments: @Model.Attachments.Count()</span>

<br />
@if (Model.Attachments.Count() > 0)
{
	foreach (var attachment in Model.Attachments)
	{
		var path = UrlHelper.GenerateContentUrl("~/Uploads/" + attachment.Name, this.ViewContext.HttpContext);
		<a href="~/Media/Image/@attachment.Id">
			<img src="@path" width="240" height="180"/>
		</a>
	}
}

<br />

@if (Model.Comments.Count() > 0)
{
	foreach (var comment in Model.Comments)
	{
		<div>
			<h4>@string.Format("{0} {1}", comment.UserName, comment.Date)</h4>
			<p>@comment.Body</p>
		</div>
	}
}

@if (Request.IsAuthenticated)
{
	using (Html.BeginForm())
	{
		<input type="hidden" name="id" value="@Model.Id" />
		<textarea rows="5" name="comment"></textarea>
		<input type="submit" value="Add" />
	}
}